//
//  ZCTabBarController.m
//  SSMusic
//
//  Created by 张灿 on 16/4/18.
//  Copyright © 2016年 张灿. All rights reserved.
//

#import "ZCTabBarController.h"
#import "ZCNavVC.h"
#import "ZCDiscoverVC.h"
#import "ZCMyMusicTableVC.h"
#import "ZCFriendTableVC.h"
#import "ZCAccountTableVC.h"

@interface ZCTabBarController ()

@end

@implementation ZCTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    //添加所有子控制器
    [self addAllChildVC];
    
    [self setTabBar];
    
}

//添加所有子控制器
- (void)addAllChildVC
{
    //发现音乐
    ZCDiscoverVC *discoverVC = [[ZCDiscoverVC alloc] init];
    [self setOneChildVC:discoverVC image:@"cm2_btm_icn_discovery" selectImage:@"cm2_btm_icn_discovery_prs" title:@"发现音乐"];
    
    //我的音乐
    ZCMyMusicTableVC *myMusicVC = [[ZCMyMusicTableVC alloc] init];
    [self setOneChildVC:myMusicVC image:@"cm2_btm_icn_music" selectImage:@"cm2_btm_icn_music_prs" title:@"我的音乐"];
    
    //朋友
    ZCFriendTableVC *friendVC = [[ZCFriendTableVC alloc] init];
    [self setOneChildVC:friendVC image:@"cm2_btm_icn_friend" selectImage:@"cm2_btm_icn_friend_prs" title:@"朋友"];
    
    //账号
    ZCAccountTableVC *accountVC = [[ZCAccountTableVC alloc] init];
    [self setOneChildVC:accountVC image:@"cm2_btm_icn_account" selectImage:@"cm2_btm_icn_account_prs" title:@"账号"];
}

//设置一个子控制器的item
- (void)setOneChildVC:(UIViewController *)VC image:(NSString *)image selectImage:(NSString *)selectImage title:(NSString *)title
{
    //给每一个子控制器设置一个导航控制器
    ZCNavVC *nav = [[ZCNavVC alloc] initWithRootViewController:VC];
    VC.navigationItem.title = title;
    
    VC.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    VC.tabBarItem.selectedImage = [[UIImage imageNamed:selectImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    VC.tabBarItem.title = title;
    
    
    [self addChildViewController:nav];
    
}

//设置tabBar的背景色,透明度等
- (void)setTabBar
{
    //设置背景色
    self.tabBar.barTintColor = [UIColor blackColor];
    self.tabBar.alpha = 0.9;
    
    //设置所有出现的文字所在状态的颜色
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0],NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
    
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:167/255.0 green:167/255.0 blue:167/255.0 alpha:1.0],NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
